﻿using MvcWechat.XcxHelper;
using System.Collections.Generic;
using System.Configuration;
using MvcWechat.Common;

namespace MvcWechat.Services
{
    public class XcxConfigs
    {
        public static List<XcxConfig> xcxConfig { get; set; }
        /// <summary>
        ///获取用户访问小程序日留存(用于团队管理)
        /// </summary>
        public static string GetAnalysisDailyRetainUrl { private set; get; }

        /// <summary>
        /////获取用户访问小程序月留存-->
        /// </summary>
        public static string GetAnalysisMonthlyRetainUrl { private set; get; }

        /// <summary>
        ////访问小程序周留存-->
        /// </summary>
        public static string GetAnalysisWeeklyRetainUrl { private set; get; }

        /// <summary>
        /////用户访问小程序数据概况-->
        /// </summary>
        public static string GetAnalysisDailySummaryUrl { private set; get; }


        /// <summary>
        /////用户访问小程序数据日趋势-->
        /// </summary>
        public static string GetAnalysisDailyVisitTrendUrl { private set; get; }


        /// <summary>
        ////户访问小程序数据月趋势-->
        /// </summary>
        public static string GetAnalysisMonthlyVisitTrendUrl { private set; get; }

        /// <summary>
        /////访问小程序数据周趋势-->
        /// </summary>
        public static string GetAnalysisWeeklyVisitTrendUrl { private set; get; }

        /// <summary>
        /////小程序新增或活跃用户的画像分布数
        /// </summary>
        public static string GetAnalysisUserPortraitUrl { private set; get; }

        /// <summary>
        /////用户小程序访问分布数据-->
        /// </summary>
        public static string GetAnalysisVisitDistributionUrl { private set; get; }

        /// <summary>
        /////面。目前只提供按 page_visit_pv 
        /// </summary>
        public static string GetAnalysisVisitPageUrl { private set; get; }

        public static XcxTokenHelper XcxTokenHelper { private set; get; }
        public static Dictionary<string, ConfigSettings> listConfigSettings { private set; get; }
        public static void Register()
        {
           listConfigSettings = CommonPage.SuppplierAllKey;

            GetAnalysisDailyRetainUrl = ConfigurationManager.AppSettings["GetAnalysisDailyRetainURL"];
            GetAnalysisMonthlyRetainUrl = ConfigurationManager.AppSettings["GetAnalysisMonthlyRetainURL"];
            GetAnalysisWeeklyRetainUrl = ConfigurationManager.AppSettings["GetAnalysisWeeklyRetainURL"];
            GetAnalysisDailySummaryUrl = ConfigurationManager.AppSettings["GetAnalysisDailySummaryURL"];
            GetAnalysisDailyVisitTrendUrl = ConfigurationManager.AppSettings["GetAnalysisDailyVisitTrendURL"];

            GetAnalysisMonthlyVisitTrendUrl = ConfigurationManager.AppSettings["GetAnalysisMonthlyVisitTrendURL"];
            GetAnalysisWeeklyVisitTrendUrl = ConfigurationManager.AppSettings["GetAnalysisWeeklyVisitTrendURL"];
            GetAnalysisUserPortraitUrl = ConfigurationManager.AppSettings["GetAnalysisUserPortraitURL"];
            GetAnalysisVisitDistributionUrl = ConfigurationManager.AppSettings["GetAnalysisVisitDistributionURL"];
            GetAnalysisVisitPageUrl = ConfigurationManager.AppSettings["GetAnalysisVisitPageURL"];

            foreach (var config in listConfigSettings)
            {
                if (config.Value != null)
                {
                    if (config.Value.AppIDByXcx != "" && config.Value.AppSecretByXcx != "")
                    {
                        XcxTokenHelper = new XcxTokenHelper(config.Value.AppIDByXcx, config.Value.AppSecretByXcx, 6200);
                        XcxTokenHelper.Run();
                    }
                }
            }
           
        }
    }
    public class XcxConfig
    {
        /// <summary>
        /// 小程序 name
        /// </summary>
        public  string XcxName { private set; get; }
        
        /// <summary>
        /// 小程序AppId
        /// </summary>
        public  string AppID { private set; get; }
        /// <summary>
        /// 小程序AppSecret
        /// </summary>
        
        public  string AppSecret { private set; get; }

       

    }
}
